package com.pkk.penguin.frame.know.java.driven.support;

import com.pkk.penguin.frame.know.java.driven.bean.JavaBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;

/**
 * @description: javabean的依赖注入到ioc容器中的支持
 * @author: peikunkun
 * @create: 2020-07-17 11:48
 **/
//相当于告诉容器此类是配置文件类
@Slf4j
@Configuration
public class JavaBeanInjectionSupport {

  /**
   * @Description: 创建bean并注入的ioc容器中【方法名为beanId值(beanName)】
   * @return: com.pkk.penguin.frame.know.java.driven.bean.JavaBean
   * @Author: peikunkun
   * @Date: 2020/7/17 0017 上午 11:50
   */
  @Lazy
  @Scope(value = "singleton")
  @Bean(initMethod = "init", destroyMethod = "destory")
  public JavaBean javaBean() {
    log.info(this.getClass().getSimpleName() + "方法执行初始化操作【JavaBean】");
    return new JavaBean(1L, "javaBean");
  }


}
